using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Patchy
{
    class MyFile : IComparable
    {
        private string mOriginalName;
        private string mNormalisedName;
        private string mShortenedName;
        private string mDestinedName;
        private int mLongestNameLength;

        public MyFile(string original, string name)
        {
            mOriginalName = original;
            mNormalisedName = name;
        }

        public string OriginalName
        {
            get { return mOriginalName; }
        }

        public string NormalisedName
        {
            get { return mNormalisedName; }
        }

        public string ShortenedName
        {
            get { return mShortenedName; }
            set { mShortenedName = value; }
        }

        public string DestinedName
        {
            get { return mDestinedName; }
            set { mDestinedName = value; }
        }

        public string FileNamePart
        {
            get { return Path.GetFileName(mNormalisedName); }
        }

        /*public string DirNamePart
        {
            get { return Path.GetDirectoryName(mNormalisedName) + Path.DirectorySeparatorChar; }
        }*/

        public string ShortenedDirNamePart
        {
            get { return Path.GetDirectoryName(mShortenedName) + Path.DirectorySeparatorChar; }
        }

        public void CalculateDestinedName(string targetDir)
        {
            string sname = Path.GetFileName(mNormalisedName);
            mDestinedName = Path.Combine(targetDir, sname);
        }

        public int LongestNameLength
        {
            set { mLongestNameLength = value; }
        }

        public int Padding
        {
            get { return mLongestNameLength - mShortenedName.Length; }
        }

        #region IComparable Members

        public int CompareTo(object obj)
        {
            if(obj is MyFile)
            {
                return string.Compare(this.NormalisedName, ((MyFile)obj).NormalisedName, true);
            }
            throw new ArgumentException("Invalid Myfile in comparision");
        }

        #endregion
    }
}
